<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>state状态</title>
</head>
<body>
      <!-- 准备容器 -->
  <div id="test"></div>
  <!-- 按照顺序引入 -->
  <script type="text/javascript" src="../../js/react.development.js"></script>
  <script type="text/javascript" src="../../js/react-dom.development.js"></script>
  <script type="text/javascript" src="../../js/babel.min.js"></script>
  <script type="text/babel" >
    class Weather extends React.Component {
      // 类中可以直接写赋值语句
      state = {isHot:false,wind:'微风'}
      render () { 
        return <h1 id="title" onClick={this.changeWeather}>今天天气很{this.state.isHot ?'炎热':'凉爽'},{this.state.wind}</h1>
      }
      // 自定义方法   要用赋值语句的形式+箭头函数
      changeWeather = ()=>{   // 必须用箭头函数  箭头函数没有自己的this  在箭头函数中写this  不会报错  会去找其外层函数的this使用
        const isHot =  this.state.isHot
        this.setState({isHot:!isHot})
      }
    }
    ReactDOM.render(<Weather/>,document.getElementById('test'))
  </script>
</body>
</html>